package com.etoak.common.core.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {

    public Integer code;

    public String message;

    public T data;

    public static final int SUCCESS_CODE = 200;

    public static final String SUCCESS_MESSAGE = "success";

    public static final int FAILED_CODE = 20000;
/** 未捕获的异常*/
    public static final String FAILED_MESSAGE = "系统异常!";

    /**
     * 给添加更新删除接口使用的
     * 不需要返回数据
     * @return
     * @param <T>
     */
    public static <T> ResultVO<T> success() {
        return success(null);
    }

    /**
     * 给需要返回数据的接口调用
     * @param data
     * @return
     * @param <T>
     */
    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<>(SUCCESS_CODE, SUCCESS_MESSAGE, data);
    }

    public static <T> ResultVO<T> failed(int code,String message) {
        return new ResultVO<>(code,message,null);
    }
    public static <T> ResultVO<T> failed() {
        return failed(FAILED_MESSAGE);
    }
    public static <T> ResultVO<T> failed(String message) {
        return failed(FAILED_CODE,message);
    }
    public static final int HTTP_METHOD_NOT_SUPPORT_CODE = 405;

    public static final String HTTP_METHOD_NOT_SUPPORT_MESSAGE = "请求方法错误！";

    public static final int HTTP_MEDIA_TYPE_NOT_SUPPORT_CODE = 415;

    public static final String HTTP_MEDIA_TYPE_NOT_SUPPORT_MESSAGE = "请求参数类型错误！";



}
